<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common-app/taglibs.jsp"%>
<!DOCTYPE html>
<head>
<link href="${res_app}/css/wuxi.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript"
	src="${res}/js/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript" src="${res}/js/public.js"></script>
<script type="text/javascript"
	src="${res_app}/js/app/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript" src="${res_app}/js/app/project/irisPrpProject.js"></script>
<title>受理申请书</title>
<style type="text/css">
.button_orange {
	height: 25px;
	font-size: 12px;
	color: #cc3300;
	border: 1px #cc9933 solid;
	background: url(${res}/images/button_orange.gif);
	padding: 0 15px;
	*padding: 0 10px;
	_padding: 0 10px;
	cursor: pointer;
}
</style>
</head>
<body>
<cpt:helpTips key="prpapproveTips4scs" id="prpapproveTips4scs"></cpt:helpTips>
	<input type="hidden" id="childDiv" class="thickbox" />
	<form method="post" id="mainForm">
		<input type="hidden" id="prpCodes" name="prpCodes" value="" /> <input
			type="hidden" id="type" name="type" value="" />
	</form>
	<br />
	<div class="soBox">
		<div class="detail ico_search">
		
			<table>
					<tr>
					<td align="right" style="width:128px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;项目类别：</td>
					<td >
		            <c:set var="grant">{'id':'${grantCode}','name':'${grantCname}'}</c:set>
						<input name="grantCname_hideId" type="hidden"  id="grantCname_hideId"  value="${grantCode}" >
						<input name="grantCname" type="hidden"  id="grantCname"  value="${grantCname}" >
	                    <security:authorize ifNotGranted="A_AUTH_DW,A_AUTH_DEPT">
						<cpt:tree id="grant" width="125px;"   key="evgrant_code_tree" name="grant" value="${grant}" className="input_text_select"  onClick="initSubjectTreeValueExp2"  sqlParamVal=""  checkable="false" readonly="true" label="业务类别" ></cpt:tree>
	                    </security:authorize>
	                    <security:authorize ifAnyGranted="A_AUTH_DW,A_AUTH_DEPT">
						<cpt:tree id="grant" width="125px;"   key="evgrant_code_tree4Org" name="grant" value="${grant}" className="input_text_select"  onClick="initSubjectTreeValueExp2"  sqlParamVal=""  checkable="false" readonly="true" label="业务类别" ></cpt:tree>
						</security:authorize>
						<input name="grant_code" type="hidden"  id="grant_code"  value="${grant_code}" >	
	             </td>
					<td align="left"  style="width:85px;">&nbsp;&nbsp;技术领域：</td>
					<td>
					   &nbsp;&nbsp;&nbsp;&nbsp;<c:set var="research">{'id':'${research_value}','name':'${researchName}'}</c:set>
						<input name="researchCname_hideId" type="hidden"  id="researchCname_hideId"  value="${research_value}" >
						<input name="researchCname" type="hidden"  id="researchCname"  value="${researchName}" >
						<cpt:tree id="research"  width="108px;" key="technosphere" name="research" value="${research}" className="input_text_select" onClick="initSubjectTreeValueExp"   checkable="false" readonly="true" label="技术领域" ></cpt:tree>
						<input name="research_value" type="hidden"  id="research_value"  value="${research_value}" >	
					</td>
					<td align="left"  style="width:60px;">专题名称：</td>
					<td align="left">
						<c:set var="domain">{'id':'${domain_value}','name':'${domainName}'}</c:set>
						<input name="domainCname_hideId" type="hidden"  id="domainCname_hideId"  value="${domain_value}" >
						<input name="domainCname" type="hidden"  id="domainCname"  value="${domainName}" >
						<cpt:tree id="domain" width="127px;" key="domain1" name="domain" value="${domain}" className="input_text_select" onClick="initSubjectTreeValueExp"  sqlParamVal="" checkable="false" readonly="true" label="专题名称" ></cpt:tree>
						<input name="domain_value" type="hidden"  id="domain_value"  value="${domain_value}" >	
					</td>
					</tr>
					<tr><td style="height:11px;"></td></tr>
			</table>
			<table>
				<tr>
					<td rowspan="2"><strong>检索条件：</strong></td>
					<td><cpt:search key="prpApprove_for_papper" repeatColumn="3"
							displayCount="6" leftStyle="width:90px"
							></cpt:search></td>
				</tr>
				<tr>
					<td>
						<div class="clear_h10"></div> <input type='button' id='searchBt'
						class="button_an" value='查询' /> <!-- 
					<input type='button' id='resetBT' class="button_an_clean" style="margin-left: 1em;" value='重置' onclick="cleanQueryBox();" />
				     -->
					</td>
				</tr>

			</table>
		</div>
	</div>
	<div class="clear_h10"></div>
	<div>
		<div id='TopBarMnt'></div>
		<table id='dataGrid'></table>
		<div id='dataBar'></div>
	</div>
	<form action="" method="post" id="exportExcel">
        <input type="hidden" name="searchString" id="searchString" value="" />
        <input type="hidden" name="sidx" id="sortItem" value="" />
        <input type="hidden" name="sord" id="sortType" value="" />
        <input name="grantCnameKJ" type="hidden"  id="grantCnameKJ"   >
    </form>
	<script type="text/javascript">
		var irisGrid = new IrisGrid("dataGrid", "dataBar", 'TopBarMnt');
		var prcWin = new progressWin("${res}");//初始化遮罩层

		var getSelOpt = function() {
			var g = "";
			$("input:checkbox[id^=jqg_dataGrid_]").each(function(i, obj) {
				if (obj.checked) {
					g += "," + obj.id.replace("jqg_dataGrid_", "");
				}
			});
			if (g != "") {
				g = g.substring(1);
			}
			return $.trim(g);
		};

		function showApproveDialog(type, gridObj, selectIdArray, recordRows) {
			var prpCodes = getSelOpt();
			if (recordRows == '') {
				prpCodes = selectIdArray + '';
			}
			if (prpCodes == "") {
				scmError("请选择一条记录");
				return false;
			}

			if (type == "approve") {

				var prpnum = prpCodes.split(",").length;
				var isAcceptPdf = "1";
				if (confirm("是否确认接收此" + prpnum + "份申报书纸质材料?")) {

					var options = {
						type : 'post',
						data : {
							"prpCodes" : prpCodes,
							"status" : '05',
							"isAcceptPdf" : isAcceptPdf
						},
						beforeSend : function() {
						}, // 表单提交前的回调函数
						success : function(msg) {
							if (msg == 'SQLError') {
								prcWin.closeWin();// 关闭遮罩层
								scmError("操作失败！");
							} else {
								if(msg.indexOf("成功")==-1){
									prcWin.closeWin();// 关闭遮罩层
									scmError(msg);
									//irisGrid.getGridDom().jqGrid("refresh", 1);//0是本页1是首页
									return ;
								} else if (msg.indexOf("政务网")!=-1) {
									prcWin.closeWin();// 关闭遮罩层
                                    scmError(msg);
                                    reflushBu();
                                    irisGrid.getGridDom().jqGrid("refresh", 1);//0是本页1是首页
								}
								else{
								prcWin.closeWin();// 关闭遮罩层
								scmSuccess("操作成功！");
								reflushBu();
								irisGrid.getGridDom().jqGrid("refresh", 1);//0是本页1是首页
								}
							}
						},// 表单成功提交后的回调函数
						error : function() {
							scmError("操作失败！");
							prcWin.closeWin();
						},
						url : "${ctx}/prpapprove/updateCheckedForPaper"
					};
					$.ajax(options);
				}
			}else if (type == "accept") {
				var prpnum = prpCodes.split(",").length;
				if (confirm("是否确认受理此" + prpnum + "份申请书?")) {
					var url = "${ctx}/prpapprove/accept-operate?prpCodes="+prpCodes+"&status=06"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
					tb_show("申报书受理意见（最多为500字）", url, false);
				}
	        }else if (type == "cancle") {
	        	var prpnum = prpCodes.split(",").length;
				if (confirm("是否确认取消受理此" + prpnum + "份申请书?")) {
				var url = "${ctx}/prpapprove/accept-operate?prpCodes="+prpCodes+"&status=07"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
						tb_show("申报书取消受理意见（最多为500字）", url, false);
				}
			}

			else if (type == "notice") {
				var prpnum = prpCodes.split(",").length;
				var isNotice = "1";

				if (confirm("是否确认短信通知此" + prpnum + "份申请书的项目负责人和单位联系人?")) {

					var options = {
						type : 'post',
						data : {
							"prpCodes" : prpCodes,
							"isNotice" : isNotice
						},
						beforeSend : function() {
						}, // 表单提交前的回调函数
						success : function(msg) {
							try {
								scmSuccess(msg);
								prcWin.closeWin();
								irisGrid.getGridDom().jqGrid("refresh", 1);//0是本页1是首页
							} catch (e) {
							}
						},// 表单成功提交后的回调函数
						error : function() {
							scmError("操作失败！");
							prcWin.closeWin();
						},
						url : "${ctx}/prpapprove/sentEmailNotice?smsCode=${smsTmpCode}&smsCustomCode=${smsCustomTmpCode}"
					};
					$.ajax(options);

				}
			}else if (type == "noticeEmail") {
				var prpnum = prpCodes.split(",").length;
				var isNotice = "1";

				if (confirm("是否确认邮件通知此" + prpnum + "份申请书的项目负责人和单位联系人及项目联系人?")) {

					var options = {
						type : 'post',
						data : {
							"prpCodes" : prpCodes,
							"isNotice" : isNotice,
                            "isSendMail" : "true"
						},
						beforeSend : function() {
						}, // 表单提交前的回调函数
						success : function(msg) {
							try {
								if(msg == 'success') {
								scmSuccess("发送成功");
								}
								prcWin.closeWin();
								irisGrid.getGridDom().jqGrid("refresh", 1);//0是本页1是首页
							} catch (e) {
							}
						},// 表单成功提交后的回调函数
						error : function() {
							scmError("操作失败！");
							prcWin.closeWin();
						},
						url : "${ctx}/prpapprove/sentEmailNotice?mailCode=${mailTmpCode}&mailCustomCode=${mailCustomTmpCode}"
					};
					$.ajax(options);

				}
			}else if (type == "prpMultiReturn"){
				var prpnum = prpCodes.split(",").length;
				if (confirm("是否确认退回这" + prpnum + "份申请书?")) {
					prpPaperReturn(prpCodes);
				}
			}
			else {
				return;
			}

		}

		var editSms = function() {
			var url = "${ctx}/sms/update-smstmp?smsCode=${smsTmpCode}&smsCustomCode=${smsCustomTmpCode}&type=${smsTemplateType}&TB_iframe=true&height=360&width=500";
			tb_show("修改短信通知模板", url, false);
		};
		var editEmail  = function() {
			var url = "${ctx}/mail/update-mailtmp?sourceTmpCodeStr=${mailTmpCode}&tmpCodeStr=${mailCustomTmpCode}&TB_iframe=true&height=360&width=700";
			tb_show("修改邮件通知模板", url, false);
		};
		/** 表格初始化**/
		//loadIrisGrid("${res}");
		function buildGrid() {

		
			var columnAttrList = new Array();
			columnAttr = new ColumnAttr("项目类别", "grant_name", "grant_name", 4,
					"left", true);
			columnAttrList.push(columnAttr);

			columnAttr = new ColumnAttr("项目名称", "zh_title", "zh_title", 6,
					"left", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
			columnAttrList.push(columnAttr);
// 			columnAttr = new ColumnAttr("项目类型", "proposal_type_name","proposal_type_name", 4, "center", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
// 			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("申报单位", "org_name", "org_name", 6,
					"left", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
			columnAttrList.push(columnAttr);
			<security:authorize ifAnyGranted="A_AUTH_SCS">
			columnAttr = new ColumnAttr("所在区市", "area_name","area_name", 4, "center", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
			columnAttrList.push(columnAttr);
			</security:authorize>
			columnAttr = new ColumnAttr("项目负责人", "psn_name", "psn_name", 4,
					"center", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("技术领域", "researcharea_name","researcharea_name", 4, "center", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("专题名称", "domain_name","domain_name", 4, "center", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("提交时间", "submitDate", "submit_date", 4,
					"left", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("受理时间", "accept_date", "accept_date", 4,"left", true);
			columnAttrList.push(columnAttr);

			columnAttr = new ColumnAttr("水印号", "prp_version", "prp_version", 4,
					"left", true);
			columnAttrList.push(columnAttr);

			columnAttr = new ColumnAttr("受理编号", "prp_no", "prp_no", 4, "left",
					true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("归口管理部门", "org_parent_name", "org_parent_name", 4, "left",
					true);
			columnAttrList.push(columnAttr);

			columnAttr = new ColumnAttr("工作进度", "statusName", "status", 5,
					"center", true);
			columnAttrList.push(columnAttr);

			columnAttr = new ColumnAttr("审核意见", "comment", "comment", 4,"center", false,false,"text",false,1);
			columnAttrList.push(columnAttr);

			columnAttr = new ColumnAttr("PDF", "pdf", "pdf", 4, "center", false,false,"text",false,1);
			columnAttrList.push(columnAttr);
			
			/* columnAttr = new ColumnAttr("项目比对", "fitCompare", "fitCompare", 3,"center", true,false,"text",false);
			columnAttrList.push(columnAttr); */

			/*
			columnAttr = new ColumnAttr("短信发送状态", "sms_status", "sms_status", 3,
					"center", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("短信接收状态", "rev_status", "rev_status", 3,
					"center", true);
			columnAttrList.push(columnAttr);
			*/
			columnAttr = new ColumnAttr("接收纸质材料", "is_accept_pdf",
					"is_accept_pdf", 5, "center", true, false, "text", false,1);
			columnAttrList.push(columnAttr);

			columnAttr = new ColumnAttr("status", "status", "status", 3,
					"left", false, false, "text", true,1);
			columnAttrList.push(columnAttr);

			columnAttr = new ColumnAttr("audit_status", "audit_status", "audit_status", 3,
					"left", false, false, "text", true,1);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("flagCan", "flagCan", "flagCan", 3,
					"left", false, false, "text", true,1);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("grantCode", "grantCode", "grantCode",
					3, "left", false, false, "text", true,1);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("statYear", "statYear", "statYear", 3,
					"left", false, false, "text", true,1);
			columnAttrList.push(columnAttr);

			columnAttr = new ColumnAttr("posCode", "posCode", "posCode", 3,
					"left", false, false, "text", true,1);
			columnAttrList.push(columnAttr);

			columnAttr = new ColumnAttr("grantCode", "grantCode", "grantCode",
					3, "left", false, false, "text", true,1);
			columnAttrList.push(columnAttr);

			columnAttr = new ColumnAttr("subGrantCode", "subGrantCode",
					"subGrantCode", 3, "left", false, false, "text", true,1);
			columnAttrList.push(columnAttr);

			columnAttr = new ColumnAttr("prpCode", "", "", 3, "left", false, false, "text", true,1);
			columnAttrList.push(columnAttr);

			columnAttr = new ColumnAttr("passFlag", "", "", 3, "left", false, false, "text", true,1);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("passFlag", "", "", 3, "left", false, false, "text", true,1);
			columnAttrList.push(columnAttr);

			irisGrid.setColumnAttrs(columnAttrList);

			var btn_name = "接收纸质材料";
			irisGrid.setToolsBar([
					{//工具栏建按钮
						id : 'approve',//按钮ID
						name : btn_name,//按钮名称
						trigger : function(gridObj, selectIdArray, recordRows) {//按钮onclick方法 grid本身 选中的行id 总行数
							var checkflag = true;
							var prpCodes = getSelOpt();
							prpCodes = prpCodes + "";
							var num = 0;
							var ps = prpCodes.split(",");
							if (selectIdArray.length > 0) {
								for ( var i = 0; i < ps.length; i++) {
									if ($("#isAcceptPdf_" + ps[i]).val() == 1) {
										num = num + 1;
									}
								}
							}
							if (num > 0) {
								scmError("你选择的项目中有" + num + "个项目不能执行“" + btn_name + "”，请先去除选择");
								checkflag = false;
							}

							if (checkflag) {

								showApproveDialog("approve", gridObj, selectIdArray, recordRows);
							}

						}
					},
					<security:authorize ifAnyGranted="A_AUTH_SLZX">
					{//工具栏建按钮
						id : 'prpMultiReturn',//按钮ID
						name : "退回修改",//按钮名称
						trigger : function(gridObj, selectIdArray, recordRows) {//按钮onclick方法 grid本身 选中的行id 总行数
							var checkflag = true;
							var prpCodes = getSelOpt();
							prpCodes = prpCodes + "";
							var num = 0;
							var ps = prpCodes.split(",");
							if (selectIdArray.length > 0) {
								for ( var i = 0; i < ps.length; i++) {
									if (($("#status_" + ps[i]).val() != '05' && $("#status_" + ps[i]).val() != '06') || $("#audit_status_" + ps[i]).val() != '00') {
										num = num + 1;
									}
								}
							}
							if (num > 0) {
								scmError("你选择的项目中有" + num + "个项目不能执行“" + "退回修改" + "”，请先去除选择");
								checkflag = false;
							}

							if (checkflag) {

								showApproveDialog("prpMultiReturn", gridObj, selectIdArray, recordRows);
							}

						}
					},
					</security:authorize>
					
					{
						id : 'editEmailId',
						name : '修改邮件通知模板',
						trigger : editEmail
					},

					{
						id : 'noticeEmail',
						name : '发送邮件通知',
						trigger : function(gridObj, selectIdArray, recordRows) {//按钮onclick方法 grid本身 选中的行id 总行数
							var checkflag = true;

							var prpCodes = getSelOpt();

							prpCodes = prpCodes + "";
							var num = 0;
							var ps = prpCodes.split(",");
							if (selectIdArray.length > 0) {
								for ( var i = 0; i < ps.length; i++) {

									if ($("#isAcceptPdf_" + ps[i]).val() == 1) {
										num = num + 1;
									}
								}
							}
							if (num > 0) {
								scmError("你选择的项目中有" + num + "个项目已经接收纸质材料了，不需要再发邮件通知了，请先去除选择");
								checkflag = false;
							}

							if (checkflag) {
							showApproveDialog("noticeEmail", gridObj, selectIdArray,recordRows);

						}
					}
					},
					{
                        id : 'exportPrjCollects',
                        name : '导出项目情况表',
                        trigger : exportPrjCollects
                    }


			]);
			irisGrid.setDefaultSortName("NLSSORT(grant_name,'NLS_SORT = SCHINESE_PINYIN_M'),NLSSORT(org_name,'NLS_SORT = SCHINESE_PINYIN_M'),NLSSORT(psn_name,'NLS_SORT = SCHINESE_PINYIN_M'),NLSSORT(zh_title,'NLS_SORT = SCHINESE_PINYIN_M')");//默认排序字段
			
			/* if("${status}"!=''){
				irisGrid
				.setUrl("${ctx}/prpapprove/list-for-receive-paper?stat_year=${param.stat_year}&isAcceptPdf=0");//查询url
			}else{ */
				irisGrid.setUrl("${ctx}/prpapprove/list-for-receive-paper?stat_year=${param.stat_year}");//查询url
			//}
			irisGrid.setCaption("暂写");
			
			//irisGrid.setDefaultSortorder("desc");
			irisGrid.setWidth(978);//整个表格宽度
			irisGrid.setCheckAble(true);//表格左边是否要复选框
			irisGrid.setShowRowIndex(true);//是否显示行号
			

			irisGrid.setQueryBox('searchBt', 'prpApprove_for_papper', ["grant_code", "research_value", "domain_value"]);//查询条件 按钮名，查询条件function_key
			irisGrid.setLoadComplete(function(){
				irisGrid.attendQuery = true;
                var searchString = irisGrid.preDealOnQuery()['searchString'];
                $("#searchString").val(searchString);
                $("#sortItem").val( irisGrid.getGridDom().jqGrid("getGridParam", 'sortname'));
                $("#sortType").val(irisGrid.getGridDom().jqGrid("getGridParam", 'sortorder'));
				setGray();
			});//设置grid加载完成之后的动作
			irisGrid.onSelectAll = function(selectid, isSelect) {//全选事件
				checkSelectAll();
			}
			irisGrid.onSelectRow = function(selectid, isSelect) {//选择事件	

			}

			irisGrid.build();
		}

	  var exportPrjCollects = function() {
           var formObj = $("#exportExcel");
           formObj.attr('action','${ctx}/prpapprove/exportExcelPrjPaper');  
           formObj.submit(); 
           
        };
	        
		function checkSelectAll() {
			$("input:checkbox[id^=jqg_dataGrid_]").each(function(i, obj) {
				if ($(obj).attr("disabled")) {
					$(obj).attr("checked", false);
				}
			});
		}

		jQuery(function() {
			if ("${prpstatus}" != "") {
				try {
					$("#_dyn_criteria2_field").val("prpstatus");
					_dyn_ShowCriteriaTag(document
							.getElementById("_dyn_criteria2_field"));
					$("#prpstatus").val("${prpstatus}");
				} catch (ee) {
				}
			}

			if ("${audie_date}" != "") {
				try {
					$("#_dyn_criteria2_field").val("audie_date");
					_dyn_ShowCriteriaTag(document
							.getElementById("_dyn_criteria2_field"));
					$("#audie_date").val("${audie_date}");
				} catch (ee) {
				}
			}
			buildGrid();
			setGray();
// 			$("div[class*='ui-jqgrid-bdiv']").css("overflow","hidden");
			$("#TopBarMnt").css("width","971px");
			 /*$("#dataGrid_toppager").css("display","none");
			$("#dataBar").css("display","none");
			$("a[class*='HeaderButton']").click(function(){
				$("#dataGrid_toppager").css("display","none");
			}); */
			$("#cb_dataGrid").click(function(){
				var checked=$(this).attr("checked");
				if(checked=="checked"){
					$("#dataGrid").find("td input[type='checkbox']").attr("checked","checked");
					$("#dataGrid").find("tr[class*='jqgrow']").each(function(){
						if($(this).find("td input[type='checkbox']").length<=0){
							$(this).removeClass("ui-state-highlight");
						}
					});
					
				}else{
					$("#dataGrid").find("td input[type='checkbox']").attr("checked",false);
				}
			});
			var index = 0;
			var stat_year = "";
			$("dl[id='stat_year']").find("a[class='c_item_checked']").each(function(){
				stat_year = $(this).prev().val();
				index ++;
			});
			if(index > 1)
				stat_year = "0";
			$("#research,#research_img,#research_tree_img").unbind("click").removeAttr("onclick");
			$("#research,#research_img,#research_tree_img").bind("click",function(){
				
				show_research("research",{"locale":"zh_CN","key":"technosphere","cacheable":"false","sqlParamVal":"{'grant_code':'"+$("#grantCname_hideId").val()+"','stat_year':'"+stat_year+"'}"});
			});
			$("#domain,#domain_img,#domain_tree_img").unbind("click").removeAttr("onclick");
			$("#domain,#domain_img,#domain_tree_img").bind("click",function(){
				show_domain("domain",{"locale":"zh_CN","key":"domain1","cacheable":"false","sqlParamVal":"{'grant_code':'"+$("#grantCname_hideId").val()+"','stat_year':'"+stat_year+"','researchCode':'"+$("#research_hideId").val()+"'}"});
			});
			
			
			//检查比对结果
			setTimeout("calChkResult();",1);
			interval();
		});
		/** 表格初始化**/

		//审核页面调用该方法刷新页面
		function search() {
			$("#searchBt").click();
		}

		/**查看单位信息*/
		function orgInfoView(orgCode) {
			tb_show("查看单位信息",
					"${ctx}/orgmanage/verifyorg/org-info-view?orgCode="
							+ orgCode + "&TB_iframe=true&height=460&width=950",
					false);
		}
		function viewComment(des3Prpcode) {
			var url = "${ctx}/proposal/view/audit-comment-view?posCode="
					+ des3Prpcode + "&TB_iframe=true&height=390&width=720";
			var title = "审核意见";
			showThickBox(url, title);
		}
		// 接受、取消材料
		function updateForPaper(prpCode, num) {
			var name = "";
			if (num == 1)
				name = "是否确认接收此份纸质材料?";
			if (confirm(name)) {

				var options = {
					type : 'post',
					data : {
						"prpCodes" : prpCode,
						"status"  : '05'
					
					},
					beforeSend : function() {
					}, // 表单提交前的回调函数
					success : function(msg) {
						if (msg == 'SQLError') {
							prcWin.closeWin();// 关闭遮罩层
							scmError("操作失败！");
						} else {
							prcWin.closeWin();// 关闭遮罩层
							scmSuccess("操作成功！");
							reflushBu();
							irisGrid.getGridDom().jqGrid("refresh", 0);//0是本页1是首页
							

						}
					},// 表单成功提交后的回调函数
					error : function() {
						scmError("操作失败！");
						prcWin.closeWin();
					},
					url : "${ctx}/prpapprove/updateCheckedForPaper"
				};

				$.ajax(options);

			}

		}
		
	function prpPaperReturn(prpCode){
		var url = "${ctx}/prpapprove/prp-paper-return?prpCodes="+prpCode+"&status=05&TB_iframe=true&height=250&width=410";
		tb_show("退回修改意见（最多为500字）", url, false);
	}
	function viewPrpCheckResults(prpCode){
		   tb_show("规则检查结果","${ctx}/prpapprove/prp-check-result?prpCode=" + prpCode
				     + "&flag=1&TB_iframe=true&height=460&width=824", false);
	   }
	
	//判断能否退回修改
	function beforePrpPaperReturn(prpCode){

		var options = {
				type : 'post',
				data : {
					"prpCode" : prpCode
				},
				beforeSend : function() {
				}, // 表单提交前的回调函数
				success : function(msg) {
					if (msg == 'SQLError') {
						scmError("操作失败，请联系管理员！");
						//提示不能退回
					} else if (msg == '0') {
						//可以退回
						prpPaperReturn(prpCode);
					}else if (msg == '1') {
						//不可以退回
						scmSuccess("该项目已经进入立项阶段，不能退回！");
					}
				},// 表单成功提交后的回调函数
				error : function() {
					scmError("操作失败！");
				},
				url : "${ctx}/appProject/sureUpdateCheckedForPaper"
			};

			$.ajax(options);
	}

		//判断能否退回修改
		function projectEndDate(prpCode){

			var options = {
				type : 'post',
				data : {
					"prpCode" : prpCode
				},
				beforeSend : function() {
				}, // 表单提交前的回调函数
				success : function(msg) {
					if (msg == 'SQLError') {
						scmError("操作失败，请联系管理员！");
						//提示不能退回
					} else if (msg == '1') {
						//可以退回
						beforePrpPaperReturn(prpCode);
					}else if (msg == '0') {
						if (confirm("是否确认退回这一份申请书?归口审核时间截止后，退回修改的申报书再提交将不能在归口审核通过。（如有特殊情况，科技厅会另行通知）")){
							beforePrpPaperReturn(prpCode);
						}else{
							return false;
						}
					}
				},// 表单成功提交后的回调函数
				error : function() {
					scmError("操作失败！");
				},
				url : "${ctx}/appProject/projectEndDate"
			};

			$.ajax(options);
		}

	function acceptOperate(prpCode,status,operate){
		var title="";
	    if(operate=='accept'){
	    	title="申报书受理意见（最多为500字）";
	    }else if(operate=="cancle"){
	    	title="申报书取消受理意见（最多为500字）";
	    }
		var url = "${ctx}/prpapprove/accept-operate?prpCodes="+prpCode+"&status="+status+"&operate="+operate+"&TB_iframe=true&height=250&width=430";
		//var url = "${ctx}/prpapprove/prp-paper-return?prpCodes="+prpCode+"&TB_iframe=true&height=250&width=410";
		tb_show(title, url, false);
	}
	/** 显示工作进度 */
	function showPrjProgress(keyCode,progressCode){
		var url = ctx + "/prpapprove/showPrjProgress";
		url = url + "?keyCodeStr="+keyCode+"&progressCode="+progressCode;
		url = url + "&TB_iframe=true&height=500&width=700";	
		tb_show("工作进度",url, false);
	}
	
	
	function setGray() {
		$("input:checkbox[id^=jqg_dataGrid_]").each(function(i, obj) {
			var id = $(obj).attr("id").replace("jqg_dataGrid_", "");
			 //黑名单企业标红
			var bl_org = $("#bl_org_" + id).val();
			if(bl_org >= 1){
				$("#bl_org_" + id).parent().css("background-color","#FF0000");
			}
			//黑名单个人标红
			var bl_psn = $("#bl_psn_" + id).val();
			if(bl_psn >= 1){
				$("#bl_psn_" + id).parent().css("background-color","#FF0000");
			} 
		});
		
		//检查比对结果
		setTimeout("calChkResult();",1);
		interval();
	}
	
	// 获取所有的检查中的项目
	  var getChecked = function() {
	  	var g = "";
	  	$("input[id^=isPrpChecking_]").each(function(i, obj) {
	  		if ($(this).val() == 1) {
	  			g += "," + obj.id.replace("isPrpChecking_", "");
	  		}
	  	});
	  	if (g != "") {
	  		g = g.substring(1);
	  	}
	  	return $.trim(g);
	  };
	
	
	var clearPswTip = null;
	function calChkResult() {
  		try {
  			var prpCodes = getChecked();
  			if (prpCodes != "") {
  				getCheckResults(prpCodes);
  			}
  			if (prpCodes == "") {
  				if(clearPswTip!=null)
  				window.clearInterval(clearPswTip);
  			}

  		} catch (e) {
  			if(clearPswTip!=null)
  			window.clearInterval(clearPswTip);
  		}
  	}
	
	
	function getCheckResults(prpCodes) {

	  	var options = {
	  		type : 'post',
	  		data : {
	  			'prpCodes' : prpCodes
	  		},
	  		beforeSend : function() {
	  		},
	  		success : function(msg) {
	  			if (msg == 'SQLError' || msg == 'error') {

	  			} else {
	  				for ( var i = 0; i < msg.length; i++) {
	  					var tips="";
	  					if(msg[i].isPrpChecking == 1){
	  						tips = '<span class="color_red ico_wait">检查中...</span>';
	  						$("#isPrpChecking_"+$.trim(msg[i].prpCode)).val("1");
	  						$("#isPrpCheckPass_"+$.trim(msg[i].prpCode)).val("0");
	  					}else if(msg[i].isPrpCheckPass == 1){
	  						tips = '<a href="#" onclick="viewPrpCheckResults('+"'"+$.trim(msg[i].prpCode)+"'"+');"><span class="color_green">检查通过</span></a>';
	  						$("#isPrpChecking_"+$.trim(msg[i].prpCode)).val("0");
	  						$("#isPrpCheckPass_"+$.trim(msg[i].prpCode)).val("1");
	  					}else{
	  						if(msg[i].similarPrjCount > 0){
	  							tips += '<a href="#" onclick="showPrpSimilarView('+"'"+$.trim(msg[i].prpCode)+"'"+');">';
	  							tips += '<span class="pop_bg_blue2"  name="pop_bg_blue2" title="疑似项目">'+msg[i].similarPrjCount+'</span>';
	  							tips += '</a>';
	  						}
	  						if(msg[i].similarOrgCount > 0){
	  							var v_org_code = $("#org_code_"+$.trim(msg[i].prpCode)).val();
	  							tips += "<a href='#' onclick=\"showOrgSimilarView('"+$.trim(msg[i].prpCode)+"','"+v_org_code+"'"+');">';
	  							tips += '<span class="pop_bg_blue"  name="pop_bg_blue" title="疑似单位">'+msg[i].similarOrgCount+'</span>';
	  							tips += '</a>';
	  						}
	  						if(msg[i].notFitCheckCount > 0){
	  							tips += '<a href="#" onclick="viewPrpCheckResults('+"'"+$.trim(msg[i].prpCode)+"'"+');">';
	  							tips += '<span class="pop_bg_red"  name="pop_bg_red" title="未通过检查规则">'+msg[i].notFitCheckCount+'</span>'; 
	  							tips += '</a>';
	  						}
	  						if(msg[i].needDoCheckCount > 0){
	  							tips += '<a href="#" onclick="viewPrpCheckResults('+"'"+$.trim(msg[i].prpCode)+"'"+');">';
	  							tips += '<span class="pop_bg_green" name="pop_bg_green" title="待确认检查规则">'+msg[i].needDoCheckCount+'</span>'; 
	  							tips += '</a>';
	  						}					
	  						
	  						$("#isPrpChecking_"+$.trim(msg[i].prpCode)).val("0");
	  						$("#isPrpCheckPass_"+$.trim(msg[i].prpCode)).val("0");
	  						$("#notFitCheckCount_"+$.trim(msg[i].prpCode)).val(msg[i].notFitCheckCount);
	  						$("#needDoCheckCount_"+$.trim(msg[i].prpCode)).val(msg[i].needDoCheckCount);
	  						$("#similarPrjCount_"+$.trim(msg[i].prpCode)).val(msg[i].similarPrjCount);
	  						$("#similarOrgCount_"+$.trim(msg[i].prpCode)).val(msg[i].similarOrgCount);
	  					}
	  					
	  					$("#prpCheck_"+$.trim(msg[i].prpCode)).html(tips);
  					}
	  		   }
	  		},
	  		error : function() {

	  		},
	  		url : ctx + "/appProject/getPrpCheckInfoByPrpCode"
	  	};
	  	$.ajax(options);
	  }
	
	 function showPrpSimilarView(prpCode){
			tb_show("","${ctx}/prpapprove/prp-similar-list?prpCode=" + prpCode +"&TB_iframe=true&height=460&width=820",false);
	  }
	  
	  function showOrgSimilarView(prpCode,orgCode){
			var height = window.screen.height;
     	var width = window.screen.width;
			tb_show("查看疑似单位信息","${ctx}/prpapprove/list-resemble-org?orgCode=" + orgCode
					+"&prpCode="+prpCode
					+"&TB_iframe=true&height="+height*0.8+"&width="+width*0.9+"", false);
		}
	  function initSubjectTreeValueExp2(treeId, treeNode) {
			if(treeId=="grant"){
		  		$("#research").val("");
				$("#research_hideId").val("");
				$("#research_hideName").val("");
				$("#researchCname_hideId").val("");
				$("#researchCname").val("");
				$("#research_value").val("");
				$("#domain").val("");
				$("#domain_hideId").val("");
				$("#domain_hideName").val("");
				$("#domainCname_hideId").val("");
				$("#domainCname").val("");
				$("#domain_value").val("");
				$("#grant_code").val(treeNode.id);
		  	}else if(treeId=="research"){
		  		$("#domain").val("");
				$("#domain_hideId").val("");
				$("#domain_hideName").val("");
				$("#domainCname_hideId").val("");
				$("#domainCname").val("");
				$("#domain_value").val("");
		  		$("#research_value").val(treeNode.id);
		  	}else if(treeId=="domain"){
		  		$("#domain_value").val(treeNode.id);
		  	}
			$("#"+treeId).parents("td").find("[name$='"+treeId+"Cname_hideId'],[id$='"+treeId+"Cname_hideId']").val(treeNode.id);
			var str = treeNode.name;
			var obj = treeNode.parentNode;
			while (obj != null) {
				str = obj.name + "-" + str;
				obj = obj.parentNode;
			}
			$("#"+treeId).parents("td").find("[name$='"+treeId+"Cname'],[id$='"+treeId+"Cname']").val(str.substring(str.indexOf("-")+1));
		}
	//覆盖函数
		function initSubjectTreeValueExp(treeId, treeNode) {
		  	if(treeId=="grant"){
		  		$("#research").val("");
				$("#research_hideId").val("");
				$("#research_hideName").val("");
				$("#researchCname_hideId").val("");
				$("#researchCname").val("");
				$("#research_value").val("");
				$("#domain").val("");
				$("#domain_hideId").val("");
				$("#domain_hideName").val("");
				$("#domainCname_hideId").val("");
				$("#domainCname").val("");
				$("#domain_value").val("");
				$("#grant_code").val(treeNode.id);
		  	}else if(treeId=="research"){
		  		$("#domain").val("");
				$("#domain_hideId").val("");
				$("#domain_hideName").val("");
				$("#domainCname_hideId").val("");
				$("#domainCname").val("");
				$("#domain_value").val("");
		  		$("#research_value").val(treeNode.id);
		  	}else if(treeId=="domain"){
		  		$("#domain_value").val(treeNode.id);
		  	}
			$("#"+treeId).parents("td").find("[name$='"+treeId+"Cname_hideId'],[id$='"+treeId+"Cname_hideId']").val(treeNode.id);
			$("#"+treeId).parents("td").find("[name$='"+treeId+"Cname'],[id$='"+treeId+"Cname']").val(treeNode.name.substring(treeNode.name.indexOf(".")+1));
		}
	</script>
</body>
</html>